function GetChormeInnerHTML(nodes) // 得到选择区域的内容
{
	var node = null;
	var Atitle = new Array();
	var Aurl = new Array();
	for ( var i = 0; i < nodes.length; i++) {
		node = nodes[i];
		if (node.tagName == "A") {
			if (node.textContent != "" && node.href != "") {
				Atitle.push(node.textContent);
				Aurl.push(node.href);
			}
		}
		if (node.childNodes.length > 0) {
			var aa = node.getElementsByTagName("A");
			for ( var j = 0; j < aa.length; j++) {
				if (aa[j].textContent != "" && aa[j].href != "") {

					Atitle.push(aa[j].textContent);
					Aurl.push(aa[j].href);
				}
			}
		}
	}
	chrome.extension.sendRequest( {
		msg : "Arraytitle" + JSON.stringify(Atitle)
	}); // 发送给扩展模块
	chrome.extension.sendRequest( {
		msg : "Arrayurl" + JSON.stringify(Aurl)
	});
}

chrome.extension.onRequest.addListener(function(data) {
	if (data.msg == "axy1") {
		var vv = document.getElementsByName("title");
		if (vv.length == 0)
			chrome.extension.sendRequest( {
				msg : "title" + document.title
			});
		else {
			chrome.extension.sendRequest( {
				msg : "title" + vv[0].content
			});
		}

		vv = document.getElementsByName("keywords");
		if (vv.length == 0)
			chrome.extension.sendRequest( {
				msg : "tag"
			});
		else {
			chrome.extension.sendRequest( {
				msg : "tag" + vv[0].content
			});
		}

		vv = document.getElementsByName("description");
		if (vv.length == 0)
			chrome.extension.sendRequest( {
				msg : "intro"
			});
		else {
			chrome.extension.sendRequest( {
				msg : "intro" + vv[0].content
			});
		}

		if (document.location.href)
			chrome.extension.sendRequest( {
				msg : "url" + document.location.href
			});
		else
			chrome.extension.sendRequest( {
				msg : "url"
			});

		var div = document.createElement("div");
		div.setAttribute("onclick", "return window;");
		div.setAttribute("id", "qwertyuas");
		var unsafeWindow = div.onclick();
		if (unsafeWindow.videoId) {
			chrome.extension.sendRequest( {
				msg : "album_id" + unsafeWindow.videoId
			});
		} else
			chrome.extension.sendRequest( {
				msg : "album_id"
			});

	} else if (data.msg == "axy2") {
		var sel = window.getSelection().getRangeAt(0); // 得到选择区域
		GetChormeInnerHTML(sel.cloneContents().childNodes);
	}

});
